import pygame
import random

class Goal(pygame.sprite.Sprite):
    '''
    The Goal is just an object that looks for a collision with the player. In
    this case the collision exits the program. The idea is that the collision
    should trigger a victory sequence of some kind
    '''

    def __init__(self, maze, tile_size):
        #Call the parent constructor
        pygame.sprite.Sprite.__init__(self)

        self.tile_size = tile_size

        self.size = self.tile_size / 2

        # Set height, width
        self.image = pygame.Surface([self.size, self.size])
        self.image.fill((255,0,0))

        x = random.randrange(maze._max_x)
        y = random.randrange(maze._max_y)

        # Make our top-left corner the passed-in location.
        self.rect = self.image.get_rect()
        self.rect.top = y * self.tile_size + \
                        (self.tile_size / 2) - (self.size / 2)
        self.rect.left = x * self.tile_size + \
                         (self.tile_size / 2) - (self.size / 2)

    # Find a new position for the player
    def player_hit(self, player):
        return pygame.sprite.spritecollide(self, [player], False)
